import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IResourceRecordVo } from "./types";

/* 查询预约记录列表 */
export function getPageResourceRecordAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IResourceRecordVo[]>> {
  return request({
    url: "/resourceRecord/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询预约记录对象 */
export function getFormResourceRecordAPI(
  id: number
): AxiosPromise<IResourceRecordVo> {
  return request({
    url: `/resourceRecord/${id}/form`,
    method: "get",
  });
}

export function getMyRecordAPI(): AxiosPromise<IResourceRecordVo[]> {
  return request({
    url: `/resourceRecord/my`,
    method: "get",
  });
}

/**
 * 添加预约记录
 *
 * @param data
 */
export function addResourceRecordAPI(data: any) {
  return request({
    url: "/resourceRecord",
    method: "post",
    data: data,
  });
}

/**
 * 修改预约记录
 *
 * @param id
 * @param data
 */
export function updateResourceRecordAPI(id: number, data: IResourceRecordVo) {
  return request({
    url: "/resourceRecord/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除预约记录
 *
 * @param ids
 */
export function deleteResourceRecordAPI(ids: number) {
  return request({
    url: "/resourceRecord/" + ids,
    method: "delete",
  });
}

export function getMyResourceRecordAPI(): AxiosPromise<IResourceRecordVo[]> {
  return request({
    url: `/resourceRecord/my`,
    method: "get",
  });
}
